package yl.hs.bmipfull.viewmodels;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

/**
 * PageResult
 *
 * @author 谢景广
 * @category
 * @date 2021-05-11
 */
@ApiModel(value = "分页查询结果", description = "分页查询结果")
public class PageResult<E> {
    public int pageDataSize;
    @ApiModelProperty(name = "page", value = "当前页码")
    private int page = 1;
    @ApiModelProperty(name = "records", value = "数据总数")
    private int records = 0;
    @ApiModelProperty(name = "total", value = "总页数")
    private int total = 0;
    @ApiModelProperty(name = "data", value = "当前页面数据")
    private List<E> data;
    private Object object;

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

    public PageResult(int pageSize) {
        this.pageDataSize = pageSize;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRecords() {
        return records;
    }

    public void setRecords(int records) {
        if ((records % pageDataSize) > 0) {
            this.total = (records / pageDataSize) + 1;
        } else
            this.total = (records / pageDataSize);
        this.records = records;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<E> getData() {
        return data;
    }

    public void setData(List<E> data) {
        this.data = data;
    }

    public int getPageDataSize() {
        return pageDataSize;
    }

    public void setPageDataSize(int pageDataSize) {
        this.pageDataSize = pageDataSize;
    }
}
